#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

struct ListNode {
    int val;
    ListNode* next;
    ListNode(int x) : val(x), next(NULL) {}
};

class Node {
   public:
    int val;
    Node* next;
    Node* random;

    Node(int _val) {
        val = _val;
        next = NULL;
        random = NULL;
    }
};

struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

class Solution {
    stack<int> s;

   public:
    bool validateStackSequences(vector<int>& pushed, vector<int>& popped) {
        int pos = 0;
        for (int i = 0; i < popped.size(); i++) {
            while (s.empty() || s.top() != popped[i]) {
                if (pos == popped.size()) {
                    return false;
                }
                s.push(pushed[pos++]);
            }
            if (s.top() == popped[i]) {
                s.pop();
            } else {
                return false;
            }
        }
        return true;
    }
};

int main() {
    cout << "Hello, World!";
    vector<int> pushed, popped;
    pushed.push_back(0);
    pushed.push_back(1);
    popped.push_back(1);
    popped.push_back(0);
    Solution().validateStackSequences(pushed, popped);
    return 0;
}
